﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Quanlynhasach.hethongluutru;
using Quanlynhasach.hethongxuly;
using System.Data;

namespace Quanlynhasach.hethongluutru
{
    class PhieuNhapDAO
    {
        public static DataTable LayDanhSachPhieuNhap()
        {
            string sql = "SELECT * FROM PhieuNhap";
            DataTable dt = database.ExcuQuery(sql);

            return dt;

        }
        public static DataTable LayDanhSachChiTietPhieu()
        {
            string sql = "SELECT * FROM ChiTietPhieu";
            DataTable dt = database.ExcuQuery(sql);

            return dt;

        }
        public static void ThemPhieuNhap(PhieuNhapDTO pnDTO)
        {
            string sql;
            sql = "Insert into PhieuNhap(NgayNhap) values  (";
            sql += "'" + pnDTO.NgayNhap + "')";
            database.ExcuNonQuery(sql);
        }

        public static void ThemChiTietPhieu(PhieuNhapDTO pnDTO)
        {
            string sql;
            sql = "Insert into ChiTietPhieu(MaPhieuNhap,MaSach, SoLuongNhap) values  (";
            sql += pnDTO.MaPhieuNhap + ",";
            sql += pnDTO.MaSach + ",";
            sql += "'" + pnDTO.SoLuongNhap+ "')";
            database.ExcuNonQuery(sql);
        }
    }
}
